#include <stdio.h>
#include <flgrCoreData.h>
#include <flgrCoreDataIO.h>
#include <flgrCoreCopy.h>
#include <flgrCoreTranspose.h>
#include "../macro.h"



/////////////////////////////////////////////////////////////////////////
// Test Macro for all flgr2d_convolution types
/////////////////////////////////////////////////////////////////////////
#define tstTranspose(dtype)					\
									\
  dtype rawsrc[]={105,115, 28, 41, 41, 48, 54, 57, 62, 70,		\
		   72, 76, 75, 76, 76, 78, 75, 77, 78, 76,		\
		   75, 79, 77, 76, 77, 73, 71, 64, 62, 55,		\
		   50, 44, 42, 32,123,112,100, 88, 82, 73,		\
		   73, 76, 76, 81, 85, 86, 90, 90, 93, 92,		\
		   91, 96, 96,100, 96, 98, 98, 97,102, 99,		\
		   98, 96, 99,102, 98, 93,100, 99, 94, 96,		\
		   94, 90, 88, 87, 88, 88, 85, 87, 35,  5};		\
									\
  dtype rawref[]={105, 72, 75, 50, 73, 91, 98, 94,			\
		  115, 76, 79, 44, 76, 96, 96, 90,			\
		   28, 75, 77, 42, 76, 96, 99, 88,			\
		   41, 76, 76, 32, 81,100,102, 87,			\
		   41, 76, 77,123, 85, 96, 98, 88,			\
		   48, 78, 73,112, 86, 98, 93, 88,			\
		   54, 75, 71,100, 90, 98,100, 85,			\
		   57, 77, 64, 88, 90, 97, 99, 87,			\
		   62, 78, 62, 82, 93,102, 94, 35,			\
		   70, 76, 55, 73, 92, 99, 96,  5};			\
									\
									\
									\
  FLGR_Data2D *imgsrc, *imgref, *img;					\
  FLGR_Ret ret;								\
									\
  imgsrc= flgr2d_create_pixmap(8,10,1,flgr_get_type_from_string(#dtype)); \
  imgref= flgr2d_create_pixmap(10,8,1,flgr_get_type_from_string(#dtype)); \
  img =   flgr2d_create_pixmap(10,8,1,flgr_get_type_from_string(#dtype)); \
									\
  flgr2d_import_raw_ptr(imgsrc,rawsrc);					\
  flgr2d_import_raw_ptr(imgref,rawref);					\
									\
  ret=flgr2d_transpose(img,imgsrc);				\
									\
  check_and_display_data2d(imgref,img,ret);				\
									\
  flgr2d_destroy(imgsrc);						\
  flgr2d_destroy(imgref);						\
  flgr2d_destroy(img);							\
									\
  return 1


int testTranspose_fgUINT8(void) {
  tstTranspose(fgUINT8);
}
int testTranspose_fgUINT16(void) {
  tstTranspose(fgUINT16);
}
int testTranspose_fgUINT32(void) {
  tstTranspose(fgUINT32);
}
int testTranspose_fgINT8(void) {
  tstTranspose(fgINT8);
}
int testTranspose_fgINT16(void) {
  tstTranspose(fgINT16);
}
int testTranspose_fgINT32(void) {
  tstTranspose(fgINT32);
}
int testTranspose_fgFLOAT32(void) {
  tstTranspose(fgFLOAT32);
}
int testTranspose_fgFLOAT64(void) {
  tstTranspose(fgFLOAT64);
}
int testTranspose_fgBIT(void) {
  fgBIT rawsrc[]={1,0,0,0,0,0,0,0,1,1,
		  0,0,0,0,0,0,0,0,0,1,
		  1,0,0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,0,0,1,
		  1,0,0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,0,0,1,		
		  1,0,0,0,0,0,0,0,0,1,		
		  0,0,0,1,1,1,1,0,0,1};		
									
  fgBIT rawref[]={1,0,1,0,1,0,1,0,
		  0,0,0,0,0,0,0,0,
		  0,0,0,0,0,0,0,0,
		  0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,1,
		  0,0,0,0,0,0,0,0,
		  1,0,0,0,0,0,0,0,
		  1,1,1,1,1,1,1,1};

  FLGR_Data2D *imgsrc,*imgref,*img;
  FLGR_Ret ret;

  imgsrc= flgr2d_create_pixmap(8,10,1,FLGR_BIT);
  imgref= flgr2d_create_pixmap(10,8,1,FLGR_BIT);	
  img =   flgr2d_create_pixmap(10,8,1,FLGR_BIT);	

  flgr2d_import_raw_ptr(imgsrc,rawsrc);
  flgr2d_import_raw_ptr(imgref,rawref);

  ret=flgr2d_transpose(img,imgsrc);

  check_and_display_data2d(imgref,img,ret);

  flgr2d_destroy(imgsrc);
  flgr2d_destroy(imgref);
  flgr2d_destroy(img);

  return 1;
}









